package company;

import java.util.*;
import java.util.regex.Pattern;

public class CrimeTimeTwo {
    public static void main(String[] args) {
        // 输入
        Scanner scanner = new Scanner(System.in);
        String orginalTime = scanner.nextLine();
        String splitStr = orginalTime.replace(":", "");
        List<String> inputList = new ArrayList<>();
        TreeSet<String> allList = new TreeSet<>();
        for (int i = 0; i < splitStr.length(); i++) {
            char c = splitStr.charAt(i);
            inputList.add(String.valueOf(c));
        }
        Stack<String> stack = new Stack<>();
        dfs(inputList, allList, stack);

        List <String> lst = new ArrayList<>(allList); //
        // 找出原始时间的下标+1
        int i = lst.lastIndexOf(orginalTime);
        Collections.sort(lst);
        // 如果原始时间是最后一个，说明犯罪时间落在第二天如 23：59->22:22
        if (i == lst.size()-1) {
            // 取最小数字，组合成犯罪时间
            System.out.println(lst.get(0));
        } else {
            System.out.println(lst.get(i + 1));
        }

    }

    private static void dfs(List<String> inputList,  TreeSet<String> allList,
                            Stack<String> stack) {
        if (stack.size() == 4) {
            String stack1 = stack.clone().toString().replace("[", "");
            String replace = stack1.replace("]", "");
            String replace1 = replace.replace(",", "");
            String replace2 = replace1.replace(" ", "");
            String time = replace2.substring(0,2)+":"+replace2.substring(2,4);
            if (TimePart.pattern.matcher(time).find()) {
                allList.add(time);
            }
            return;
        }
        for (int i = 0; i < inputList.size(); i++) {
            stack.push(inputList.get(i));
            dfs(inputList, allList, stack);
            stack.pop();
        }
    }

    private static class TimePart {
        private static final String regEx = "^([01]?[0-9]{1}|2[0-3]):[0-5][0-9]";
        private static final Pattern pattern = Pattern.compile(regEx);
    }
}
